<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    function ajaxpromise(url){
        return new Promise(function(resolve,reject){
            const xhr = new XMLHttpRequest()
            console.log(xhr)
            xhr.open('GET',url,false)
            xhr.onreadystatechange = function(){
                if(xhr.readyState === 4){
                    if(xhr.status === 200){
                        //alert(xhr.responseText)
                        console.log(xhr)
                        resolve(xhr.responseText)
                    }else if(xhr.status === 404){
                        reject(xhr.responseText)
                    }
                }
            }
            // xhr.send(null)
        })
        
    }
    let url = './wenti.txt'
    ajaxpromise(url)
</script>
</html>

